﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpreadsheetGear;
using WorkbookDesigner.Addons.SpreadsheetEditor.Model;
using WorkbookDesigner.Addons.SpreadsheetEditor.Presenter;

namespace WorkbookDesigner.Addons.SpreadsheetEditor.UI
{
    public partial class WFBookView : UserControl, IBookView
    {
        public WFBookView()
        {
            InitializeComponent();
        }
        public MissionPresenter Presenter { get; set; }
        public SpreadsheetGear.Windows.Forms.WorkbookView ActiveView => workbookView1;
        private void workbookView1_CellEndEdit(object sender, SpreadsheetGear.Windows.Forms.CellEndEditEventArgs e)
        {
            e.RangeSelection.Cells[0, 0].Font.Color = e.Entry.StartsWith("=") ? Colors.Red : Colors.Black;
        }

        private void toolStripMenuItemAdd_Click(object sender, EventArgs e)
        {
            Presenter.NewAction_Add(workbookView1.RangeSelection);
        }

        private void toolStripMenuItemDelete_Click(object sender, EventArgs e)
        {
            Presenter.NewAction_Delete();
        }

        private void toolStripMenuItemEdit_Click(object sender, EventArgs e)
        {
            Presenter.NewAction_Edit();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SpreadsheetGear.Windows.Forms.WorkbookExplorer we =
                new SpreadsheetGear.Windows.Forms.WorkbookExplorer(ActiveView.ActiveWorkbookSet);
            we.Show(this);
        }
    }
}
